<%@ page import="pojo.User" %>
<%@ page import="java.util.List" %>
<%@ page import="java.util.ArrayList" %>
<%@ page import="java.util.Collections" %>
<%@ page import="java.util.Date" %><%--
  Created by IntelliJ IDEA.
  User: W
  Date: 2025/9/26
  Time: 13:46
  To change this template use File | Settings | File Templates.
--%>
<%--引入JSTL标签库--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>

<%
    request.setAttribute("user",new User());
    List<Integer> list = new ArrayList<>();
    Collections.addAll(list,1,2,3,4,5,6);
    request.setAttribute("list",list);
    request.setAttribute("time",new Date());
    request.setAttribute("number",1234.5678);
%>

<html>
<head>
    <title>Title</title>
</head>
<body>
    <div>
        <c:set var="test" value="" scope="page"/>
<%--        <c:remove var="test" scope="page"/>--%>
    </div>
    <div>
<%--        <c:if test="${empty pageScope.test}">--%>
<%--            test为空--%>
<%--        </c:if>--%>
        <c:choose>
            <c:when test="${empty pageScope.test}">
                test为空
            </c:when>
            <c:when test="${pageScope.test == ''}">
                test为空字符串
            </c:when>
            <c:otherwise>
                test不为空
            </c:otherwise>
        </c:choose>
<%--        ${pageScope.test}--%>
    </div>

    <div>
        <c:set var="user" value="${user}" scope="page"/>
        <c:set target="${pageScope.user}" property="name" value="张三"/>
    </div>
    <div>
        ${pageScope.user.name}
    </div>

    <div>
        <c:forEach items="${list}" var="num" begin="1" end="5" step="2">
            ${num}
        </c:forEach>
    </div>

    <div>
        当前时间：<fmt:formatDate value="${time}" pattern="yyyy-MM-dd : hh:mm:ss"/>
    </div>

<%--    货币格式--%>
    <div>
        <fmt:formatNumber value="${number}" type="currency" />
    </div>
<%--    数字格式化--%>
    <div>
       <fmt:formatNumber value="${number}" type="number" maxIntegerDigits="3" maxFractionDigits="3"/>
    </div>
<%--    数字百分比--%>
    <div>
        <fmt:formatNumber value="${number}" type="percent" maxIntegerDigits="2" maxFractionDigits="2"/>
    </div>
</body>
</html>
